package com.common.www.bean.entity.tabulation;


import org.springframework.boot.base.jpa.domain.annotations.QueryCacheable;
import org.springframework.boot.base.jpa.domain.entity.NumberIdentityEntity;
import com.common.www.bean.entity.project.Project;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 内线标底清单
 *
 * @param
 * @author andyliu
 * @date 5/28/2018 4:23 PM
 * @return
 */
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
@Getter
@Setter
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table()
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "内线清单参数")
@JsonIgnoreProperties(ignoreUnknown=true)
public class InnerBidBaseTabulation extends NumberIdentityEntity {
    /**
     * 所属项目
     */
    @JsonIgnoreProperties(value = {"company"})
    @ManyToOne()
    private Project project;

    /**
     * 标底类型；1.标底 2.实施定标
     */
    @Column(length = 11)
    private Integer bidType;

    /**
     * 名称类型1(一.高压配电室房...六.5#低压配电房...十一.其他...十二.增补清单)。非固定类型
     */
    @Column(length = 128)
    private String nameType1;
    /**
     * 名称类型2(名称类型1为增补清单时：1#低压配电房...充电桩配电部份)。非固定类型
     */
    @Column(length = 128)
    private String nameType2;
    /**
     * 序号归属类型
     */
    @Column(length = 128)
    private String codeNumberType;

    /**
     * 序号
     */
    @Column(length = 128)
    private String codeNumber;
    /**
     * 名称
     */
    @NotNull(message = "请填写名称")
    @Length(max=128,message = "名称最长不超过128位")
    @Column(length = 128, nullable = false)
    @ApiModelProperty(value = "名称", example = "1")
    private String name;
    /**
     * 分类
     * 1.直流屏  2.高压开关柜  3.低压开关柜  4.母线槽  5.变压器  6.10kv高压电缆  7.架空线  8.低压电缆  9.预分支电缆
     * 10.电表箱  11.配电箱  12.电表  13.高压桥架  14.调试  15.电缆通道  16.电杆  17.手续费  18.措施费  19.其他
     */
    @Column(length = 12)
    private Integer fenLei;
    /**
     * 编号
     */
    @Column(length = 42)
    @Length(max=42,message = "编号最长不超过42位")
    private String classificationCode;
    /**
     * 型号
     */
    @Length(max=128,message = "型号最长不超过128位")
    @Column(length = 128)
    private String modelCode;
    /**
     * 工作内容(工程内容)
     */
    @Column(columnDefinition = "TEXT")
    private String gongZuoNeiRong;
    /**
     * 单位（eg:台、个）
     */
    @Column(length = 32)
    private String unit;
    /**
     * 分析分类
     * 变压器、低压柜、调试、高压电缆、高压柜、其他、手续费、低压电缆、配电箱、电表、电表箱、母线槽、电缆通道
     */
    @Column(length = 128)
    private String fenXiFenLei;
    /**
     * 工程量
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double gongChengLiang;

    /**
     * 住宅
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double zhuZhai;
    /**
     * 非居
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double feiJu;
    /**
     * 商业
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double shangYe;
    /**
     * 充电桩
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double chongDianZhuang;

    /**
     * 人工费
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal renGongCost;
    /**
     * 主材费(含损耗费)
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal zhuCaiCost;
    /**
     * 辅材及其他材料费
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal fuCaiCost;
    /**
     * 机械费
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal jiXieCost;
    /**
     * 企业管理费、利润、规费等
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal qiYeCost;
    /**
     * 税金
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal shuiJin;
    /**
     * 企业管理费、利润、规费等--公式填写值
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal qiYeCostFillIn;
    /**
     * 税金--公式填写值
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal shuiJinFillIn;
    /**
     * 综合单价
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal comprehensivePrice;
    /**
     * 合价
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal totalPrice;
    /**
     * 备注
     */
    @Column(length = 4096)
    @Length(max=4096,message = "备注最长不超过4096位")
    private String remarks;
    //===============================
    /**
     * 型号是否是否与全系清单一致（不一致：1,  一致：2或null）
     */
    @Column(length = 128)
    private Integer modelCodeError;
    /**
     * 工作内容是否是否与全系清单一致（不一致：1,  一致：2或null）
     */
    @Column(length = 128)
    private Integer neiRongError;
    /**
     * 税金-原始值
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal shuiJinOriginal;
    /**
     * 综合单价-原始值
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal comprehensivePriceOriginal;
    /**
     * 合价-原始值
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal totalPriceOriginal;

    /**
     * 文件名
     */
    @Column(length = 128)
    private String fileName;


    @Transient
    private String fenLeiName;

    public String getFenLeiName() {
        if (fenLei == null) {
            return null;
        }
        switch (fenLei) {
            case 1:
                return "直流屏";
            case 2:
                return "高压开关柜";
            case 3:
                return "低压开关柜";
            case 4:
                return "母线槽";
            case 5:
                return "变压器";
            case 6:
                return "10kv高压电缆";
            case 7:
                return "架空线";
            case 8:
                return "低压电缆";
            case 9:
                return "预分支电缆";
            case 10:
                return "电表箱";
            case 11:
                return "配电箱";
            case 12:
                return "电表";
            case 13:
                return "高压桥架";
            case 14:
                return "调试";
            case 15:
                return "电缆通道";
            case 16:
                return "电杆";
            case 17:
                return "手续费";
            case 18:
                return "措施费";
            case 19:
                return "其他";
        }
        return "未知";
    }


}